<template>
  <el-container style="flex-direction:column;">
    <el-form :inline="true" :model="formInline" size="mini" class="demo-form-inline">
      <el-form-item label="">
        <el-input v-model="formInline.user" placeholder="请输入名称搜索"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="success" icon="el-icon-search" @click="onSubmit">搜索</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="warning" icon="el-icon-refresh-left">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row style="padding-bottom: 10px;">
      <el-button type="primary" size="mini" icon="el-icon-plus">新增</el-button>
      <el-button type="success" size="mini" icon="el-icon-edit" :disabled="multipleSelection.length !== 1">修改</el-button>
      <el-button type="danger" size="mini" icon="el-icon-delete" :disabled="multipleSelection.length == 0">删除</el-button>
      <el-button type="warning" size="mini" icon="el-icon-download">导出</el-button>
    </el-row>
    <el-table
      @selection-change="selectionChange"
      :data="tableData" size="mini"
      style="width: 100%">
      <el-table-column align="center" header-align="center"
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="username"
        label="用户名">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="sex"
        label="性别">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="status"
        label="状态">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="createTime"
        width="180"
        label="创建日期">
      </el-table-column>
      <el-table-column label="操作" width="160" align="center" header-align="center" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"  type="primary"
            @click="handleEdit(scope.$index, scope.row)"  icon="el-icon-edit"></el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)" icon="el-icon-delete"></el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination style="margin-top: 8px;"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, prev, pager, next, sizes,jumper"
      :total="400">
    </el-pagination>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      currentPage:1,
      formInline: {
        user: '',
        region: ''
      },
      tableData: [
        {
          id:1,
          username:"admin",
          sex: "男",
          status: 0,
          createTime: "	2018-08-23 09:11:56"
        },
         {
          id:2,
          username:"test",
          sex: "女",
          status: 1,
          createTime: "	2018-09-23 09:11:56"
        }
      ],
      multipleSelection: [],
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!');
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    selectionChange(val){
      this.multipleSelection = val;
    },
  } 
}
</script>

<style>

</style>